export const Address = {
  state: {
    addressList: [
      {
        id: "1",
        name: "张三",
        tel: "13000000000",
        address: "浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室",
        isDefault: true,
      },
      {
        id: "2",
        name: "李四",
        tel: "13100000000",
        address: "浙江省杭州市拱墅区莫干山路 50 号",
      },
    ],
    address: {},
    onChangeCity:'' //首页切换城市
  },
  mutations: {
    ADD_ADDRESS(state, address) {
      state.addressList.push(address);
    },
    DEL_ADDRESS(state, id) {
      let index = state.addressList.findIndex((item) => item.id == id);
      state.addressList.splice(index, 1);
    },
    SAVE_CITY(state,city){
      state.onChangeCity=city
    }
  },
  actions: {
    addAdress({ commit }, address) {
      commit("ADD_ADDRESS", address);
    },
    delAddress({ commit }, id) {
      commit("DEL_ADDRESS", id);
    },
    saveCity({commit},city){
      commit('SAVE_CITY',city)
    }
  },
};
